from selenium.webdriver.common.by import By
from page.base_page import BasePage
class AddAccountsReceivablePage(BasePage):
    """数据准备"""
    url = "/index.php?m=finance&a=add&t=receivables"
    accounts_receivable_nmame = "吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱吱"
    accounts_receivable_amount = "100"
    #定位器
    arn_locator = (By.ID, "name")
    click_customer_locator = (By.NAME, "customer")
    btn_customer_locator = (By.XPATH, "/html/body/div[7]/div[2]/table/tbody[2]/tr[1]/td[1]/input[1]")
    click_ok_locator = (By.CSS_SELECTOR,"body > div:nth-child(8) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button:nth-child(1) > span")
    ara_locator = (By.ID, "price")
    click_save_locator = (By.NAME, "submit")
    added_successfully_name_locator=(By.CSS_SELECTOR,"body > div.container > div.alert.alert-success")
    click_cancel_locator = (By.CSS_SELECTOR,"body > div.container > div.row > div > form > table > tfoot > tr > td:nth-child(2) > input:nth-child(3)")
    one_name_locator=(By.CSS_SELECTOR,"#form1 > table > tbody > tr:nth-child(1) > td:nth-child(2) > a")
    click_asacn_locator = (By.CSS_SELECTOR,"body > div.container > div.row > div > form > table > tfoot > tr > td:nth-child(2) > input:nth-child(2)")

    def accounts_receivable_name(self,name):
        """编辑应收款名"""
        self.send_keys(self.arn_locator,name)
    def customer(self):
        """点击客户"""
        self.click(self.click_customer_locator)
    def btn_one(self):
        """选择客户"""
        self.click(self.btn_customer_locator)
    def click_ok(self):
        """点击OK"""
        self.click(self.click_ok_locator)
    def amount_received(self,amount):
        """编辑描述"""
        self.send_keys(self.ara_locator,amount)
    def save(self):
        """点击保存"""
        self.click(self.click_save_locator)
    def cancel(self):
        """点击取消"""
        self.click(self.click_cancel_locator)
    def added_successfully_name(self):
        """返回添加成功名字"""
        return self.find_element(self.added_successfully_name_locator).text
    def one_name(self):
        """返回第一个任务名字"""
        return self.find_element(self.one_name_locator).text
    def click_asacn(self):
        """点击保存并新建"""
        self.click(self.click_asacn_locator)

